package com.geek.framework.study.event.observer;

import com.geek.framework.study.event.EventListener;

/**
 * @Author: ysq
 * @Date: 2021/9/1
 * @Description: 事件触发器
 */
public class EventEmitter {
  private EventObservable observable;

  public EventEmitter() {
    this.observable = new EventObservable();
  }

  public void emit(Object event) {
    observable.notifyObservers(event);
  }

  public void addListener(EventListener listener) {
    ListenerObserverAdapter observer = new ListenerObserverAdapter(listener);
    observable.addObserver(observer);
  }

}
